.class public Lcom/estrongs/android/util/m;
.super Ljava/lang/Object;
.source "ESLock.java"


# static fields
.field private static a:Landroid/os/PowerManager;

.field private static b:Landroid/net/wifi/WifiManager;

.field private static c:Landroid/os/PowerManager$WakeLock;

.field private static d:Landroid/net/wifi/WifiManager$WifiLock;

.field private static e:Ljava/lang/Integer;

.field private static f:Ljava/lang/Integer;

.field private static g:Ljava/lang/Object;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    const/4 v0, 0x0

    .line 1
    invoke-static {v0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v0

    sput-object v0, Lcom/estrongs/android/util/m;->e:Ljava/lang/Integer;

    .line 2
    sput-object v0, Lcom/estrongs/android/util/m;->f:Ljava/lang/Integer;

    .line 3
    new-instance v0, Ljava/lang/Object;

    invoke-direct {v0}, Ljava/lang/Object;-><init>()V

    sput-object v0, Lcom/estrongs/android/util/m;->g:Ljava/lang/Object;

    return-void
.end method

.method public static a()V
    .locals 1

    const/4 v0, 0x1

    .line 1
    invoke-static {v0, v0}, Lcom/estrongs/android/util/m;->a(ZZ)V

    return-void
.end method

.method public static a(ZZ)V
    .locals 3

    .line 2
    sget-object v0, Lcom/estrongs/android/util/m;->g:Ljava/lang/Object;

    monitor-enter v0

    const/4 v1, 0x0

    const/4 v2, 0x1

    if-eqz p0, :cond_0

    .line 3
    :try_start_0
    sget-object p0, Lcom/estrongs/android/util/m;->f:Ljava/lang/Integer;

    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    add-int/2addr p0, v2

    invoke-static {p0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->f:Ljava/lang/Integer;

    .line 4
    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    if-ne p0, v2, :cond_0

    .line 5
    invoke-static {v2, v1}, Lcom/estrongs/android/util/m;->b(ZZ)V

    :cond_0
    if-eqz p1, :cond_1

    .line 6
    sget-object p0, Lcom/estrongs/android/util/m;->e:Ljava/lang/Integer;

    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    add-int/2addr p0, v2

    invoke-static {p0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->e:Ljava/lang/Integer;

    .line 7
    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    if-ne p0, v2, :cond_1

    .line 8
    invoke-static {v1, v2}, Lcom/estrongs/android/util/m;->b(ZZ)V

    .line 9
    :cond_1
    monitor-exit v0

    return-void

    :catchall_0
    move-exception p0

    monitor-exit v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw p0
.end method

.method public static b()V
    .locals 1

    const/4 v0, 0x1

    .line 18
    invoke-static {v0, v0}, Lcom/estrongs/android/util/m;->d(ZZ)V

    return-void
.end method

.method private static b(ZZ)V
    .locals 4

    const-string v0, "ES Wifi Lock"

    .line 1
    invoke-static {}, Lcom/estrongs/android/pop/FexApplication;->n()Lcom/estrongs/android/pop/FexApplication;

    move-result-object v1

    if-nez v1, :cond_0

    return-void

    .line 2
    :cond_0
    sget-object v2, Lcom/estrongs/android/util/m;->a:Landroid/os/PowerManager;

    if-nez v2, :cond_1

    if-eqz p0, :cond_1

    const-string v2, "power"

    .line 3
    invoke-virtual {v1, v2}, Landroid/app/Application;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/os/PowerManager;

    sput-object v2, Lcom/estrongs/android/util/m;->a:Landroid/os/PowerManager;

    .line 4
    :cond_1
    sget-object v2, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    if-nez v2, :cond_2

    if-eqz p1, :cond_2

    const-string v2, "wifi"

    .line 5
    invoke-virtual {v1, v2}, Landroid/app/Application;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Landroid/net/wifi/WifiManager;

    sput-object v2, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    :cond_2
    const/4 v2, 0x0

    const/4 v3, 0x1

    if-eqz p0, :cond_4

    .line 6
    sget-object p0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;

    if-eqz p0, :cond_3

    invoke-virtual {p0}, Landroid/os/PowerManager$WakeLock;->isHeld()Z

    move-result p0

    if-eqz p0, :cond_3

    goto :goto_0

    :cond_3
    const/4 p0, 0x1

    goto :goto_1

    :cond_4
    :goto_0
    const/4 p0, 0x0

    :goto_1
    if-eqz p1, :cond_6

    .line 7
    sget-object p1, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    if-eqz p1, :cond_5

    invoke-virtual {p1}, Landroid/net/wifi/WifiManager$WifiLock;->isHeld()Z

    move-result p1

    if-eqz p1, :cond_5

    goto :goto_2

    :cond_5
    const/4 v2, 0x1

    :cond_6
    :goto_2
    if-eqz p0, :cond_7

    .line 8
    sget-object p0, Lcom/estrongs/android/util/m;->a:Landroid/os/PowerManager;

    if-eqz p0, :cond_7

    .line 9
    invoke-virtual {v1}, Landroid/app/Application;->getPackageName()Ljava/lang/String;

    move-result-object p1

    const-string v1, ":ES Wake Lock"

    invoke-virtual {p1, v1}, Ljava/lang/String;->concat(Ljava/lang/String;)Ljava/lang/String;

    move-result-object p1

    invoke-virtual {p0, v3, p1}, Landroid/os/PowerManager;->newWakeLock(ILjava/lang/String;)Landroid/os/PowerManager$WakeLock;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;

    .line 10
    invoke-virtual {p0}, Landroid/os/PowerManager$WakeLock;->acquire()V

    :cond_7
    if-eqz v2, :cond_9

    .line 11
    sget-object p0, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    if-eqz p0, :cond_9

    .line 12
    invoke-static {}, Lcom/estrongs/android/pop/k;->b()I

    .line 13
    :try_start_0
    sget-object p0, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    const/4 p1, 0x3

    invoke-virtual {p0, p1, v0}, Landroid/net/wifi/WifiManager;->createWifiLock(ILjava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    if-nez p0, :cond_8

    .line 14
    sget-object p0, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    invoke-virtual {p0, v3, v0}, Landroid/net/wifi/WifiManager;->createWifiLock(ILjava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_3

    :catch_0
    :try_start_1
    const-string p0, "Error"

    const-string p1, "change to acquire WIFI_MODE_FULL lock"

    .line 15
    invoke-static {p0, p1}, Lcom/estrongs/android/util/n;->b(Ljava/lang/String;Ljava/lang/String;)V

    .line 16
    sget-object p0, Lcom/estrongs/android/util/m;->b:Landroid/net/wifi/WifiManager;

    invoke-virtual {p0, v3, v0}, Landroid/net/wifi/WifiManager;->createWifiLock(ILjava/lang/String;)Landroid/net/wifi/WifiManager$WifiLock;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    .line 17
    :cond_8
    :goto_3
    sget-object p0, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {p0}, Landroid/net/wifi/WifiManager$WifiLock;->acquire()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    :catch_1
    :cond_9
    return-void
.end method

.method private static c(ZZ)V
    .locals 1

    const/4 v0, 0x0

    if-eqz p1, :cond_0

    .line 1
    :try_start_0
    sget-object p1, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    if-eqz p1, :cond_0

    sget-object p1, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {p1}, Landroid/net/wifi/WifiManager$WifiLock;->isHeld()Z

    move-result p1

    if-eqz p1, :cond_0

    .line 2
    sget-object p1, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    invoke-virtual {p1}, Landroid/net/wifi/WifiManager$WifiLock;->release()V

    .line 3
    sput-object v0, Lcom/estrongs/android/util/m;->d:Landroid/net/wifi/WifiManager$WifiLock;

    :cond_0
    if-eqz p0, :cond_1

    .line 4
    sget-object p0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;

    if-eqz p0, :cond_1

    sget-object p0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;

    invoke-virtual {p0}, Landroid/os/PowerManager$WakeLock;->isHeld()Z

    move-result p0

    if-eqz p0, :cond_1

    .line 5
    sget-object p0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;

    invoke-virtual {p0}, Landroid/os/PowerManager$WakeLock;->release()V

    .line 6
    sput-object v0, Lcom/estrongs/android/util/m;->c:Landroid/os/PowerManager$WakeLock;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    :catch_0
    :cond_1
    return-void
.end method

.method public static d(ZZ)V
    .locals 3

    .line 1
    sget-object v0, Lcom/estrongs/android/util/m;->g:Ljava/lang/Object;

    monitor-enter v0

    const/4 v1, 0x0

    const/4 v2, 0x1

    if-eqz p0, :cond_0

    .line 2
    :try_start_0
    sget-object p0, Lcom/estrongs/android/util/m;->f:Ljava/lang/Integer;

    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    sub-int/2addr p0, v2

    invoke-static {p0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->f:Ljava/lang/Integer;

    .line 3
    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    if-nez p0, :cond_0

    .line 4
    invoke-static {v2, v1}, Lcom/estrongs/android/util/m;->c(ZZ)V

    :cond_0
    if-eqz p1, :cond_1

    .line 5
    sget-object p0, Lcom/estrongs/android/util/m;->e:Ljava/lang/Integer;

    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    sub-int/2addr p0, v2

    invoke-static {p0}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object p0

    sput-object p0, Lcom/estrongs/android/util/m;->e:Ljava/lang/Integer;

    .line 6
    invoke-virtual {p0}, Ljava/lang/Integer;->intValue()I

    move-result p0

    if-nez p0, :cond_1

    .line 7
    invoke-static {v1, v2}, Lcom/estrongs/android/util/m;->c(ZZ)V

    .line 8
    :cond_1
    monitor-exit v0

    return-void

    :catchall_0
    move-exception p0

    monitor-exit v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    throw p0
.end method
